var data;
$.ajax({
	url : "../../assets/data/area-select/area.json",
	async : false,
	success : function(d) {
		data = d;
	},
	dataType:"json"
});
var province = data.province;
var city = data.city;
var district = data.district;
// 给省下拉框赋值
var html_province = "<option value='_null'>选择省</option>";
$.each(province, function(index, p) {
	html_province += "<option value='" + p.id + "'>" + p.name + "</option>";
});
$("#province_id").html(html_province);
//给市下拉框赋值
var html_city = "<option value='_null'>选择市</option>";
$.each(city, function(index, p) {
	html_city += "<option value='" + p.id + "'>" + p.name + "</option>";
});
$("#city_id").html(html_city);
//给区下拉框赋值
var html_district = "<option value='_null'>选择区</option>";
$.each(district, function(index, p) {
	html_district += "<option value='" + p.id + "'>" + p.name + "</option>";
});
$("#district_id").html(html_district);
// 给省下拉框绑定事件
$("#province_id").change(
		function() {
			var p_id = $(this).val();
			var html_city = "<option value='_null'>选择市</option>";
			$.each(city, function(index, c) {
				if (c.parent_id === p_id) {
					html_city += "<option value='" + c.id + "'>" + c.name
							+ "</option>";
				}
			});
			$("#city_id option[value=_null]").attr("selected", true);
			$("#district_id option[value=_null]").attr("selected", true);
		});
// 给市下拉框绑定事件
$("#city_id").change(
		function() {
			var p_id = $(this).val();
			var html_district = "<option value='_null'>选择区</option>";
			$.each(district, function(index, d) {
				if (d.parent_id === p_id) {
					html_district += "<option value='" + d.id + "'>" + d.name
							+ "</option>";
				}
			});
			$("#district_id option[value=_null]").attr("selected", true);
		});
